package com.mxpio.erp.common.handler;

import com.mxpio.erp.common.enums.BizExceptionEnums;
import com.mxpio.erp.common.enums.OaEnums;
import com.mxpio.erp.common.enums.OrderStatusEnums;
import com.mxpio.erp.common.util.AssertUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * 工单状态校验机
 */
@Slf4j
public class WorkerOrderStatusManager {

    /**
     * 工单状态提交校验
     * @param orderStatusCode
     * @param bpmnStatusCode
     * @return
     */
    public static void submitValidate(String orderStatusCode, String bpmnStatusCode) {
        try {

            AssertUtil.isFalse(orderStatusCode.equals(OaEnums.OrderStatus.UNDER_REVIEW.getCode())
                            || bpmnStatusCode.equals(OrderStatusEnums.BpmnStatus.AUDITING.getStatusCode()),
                    BizExceptionEnums.ORDER_AUDITING);

            AssertUtil.isFalse(orderStatusCode.equals(OaEnums.OrderStatus.CLOSED.getCode())
                    || orderStatusCode.equals(OaEnums.OrderStatus.DONE.getCode()),
                    BizExceptionEnums.ORDER_CLOSED_OR_FINISH);

            AssertUtil.isTrue(orderStatusCode.equals(OaEnums.OrderStatus.NEW.getCode()),
                    BizExceptionEnums.ORDER_CLOSED_OR_FINISH);

        } catch (Exception e) {
            throw e;
        }
    }

}
